var app = getApp();
var e = [{
  icon: "/images/kaoshijilu.png",
  title: "我的成绩",
  msg: "",
  showRight: 1
},
{
  icon: "/images/paiming.png",
  title: "成绩排名",
  msg: "",
  showRight: 1
},{
  icon: "/images/share.png",
  title: "邀请好友",
  msg: "",
  showRight: 1
},
//   {
//   icon: "/images/icon_computer.png",
//   title: "电脑登录",
//   msg: "",
//   showRight: 1
// },
  {
  icon: "/images/about_we.png",
  title: "关于我们",
  msg: "",
  showRight: 1
}, {
  icon: "/images/qingli.png",
  title: "缓存清理",
  msg: "",
  showRight: 1
}];

Page({
  data: {
    cellList: e,
    userInfo: {},
    is_login: true,
    modalHidden: true
  },
  onLoad: function (e) {
  },
  onShow: function () {
    var a = this;
   
    this.setData({
      userInfo: wx.getStorageSync('userInfo')
    })
  },
  go_view: function (e) {
    switch (1 * e.currentTarget.dataset.viewind) {
      case 0:
        if (this.data.userInfo.avatarUrl == undefined || this.data.userInfo.avatarUrl == '') {
          this.login()
          return
        }
        wx.navigateTo({
          url: '../grade/grade',
        })
        break;
      case 1:
        this.scoreRanking()
        break;  
      case 2:
        break;
      case 3:
        this.PCLoginMsc()
        break;  
      case 4:
        this.about()
        break;
      case 5:
        this.qingli()
        break;
    }
  },
  scoreRanking: function () {
    setTimeout(function () {
      wx.navigateTo({
        url: "/pages/rank/rank"
      });
    }, 30);
  },
  about() {
    wx.showModal({
      title: '关于我们',
      content: '企业综合在线平台',
      showCancel: false
    })
  },
  qingli() {
    wx.clearStorage();
    wx.navigateTo({
      url: '../start/start',
    })
  },
  PCLoginMsc() {
    var uid = wx.getStorageSync('uid');
    wx.request({
      url: app.globalData.url + app.interfaceAddress.getCurrentUserInfo,
      method: 'get',
      dataType: 'json',
      data: {
        userId: uid,
      },
      success: function (res) {
        wx.showModal({
          title: '电脑端登录信息',
          content: '登录网址: www.soft580.com \r\n 用户名：'+res.data.data.loginName+' \r\n 初始密码：'+res.data.data.remark,
          showCancel: false
        })
      }
    })
   
  },
  onShareAppMessage: function () {
    return {
      title: "企业综合在线平台！",
      path: "pages/start/start",
      imageUrl: "https://www.soft580.com/profile/share.jpg"
    };
  },
  hintTip: function () {
    wx.showModal({
      title: '温馨提示',
      content: '功能未开放，敬请期待！',
      showCancel: false
    })
  },

  login() {
    this.setData({
      is_login: !this.data.is_login
    })
  },
  getUserProfile: function (e) {
    this.login()
    
    var that = this;
    wx.getUserProfile({
      desc: '完善信息',
      success: function (res) {
        
       wx.setStorageSync('userInfo', res.userInfo);
       that.setData({
         userInfo: res.userInfo
       });
        var uid = wx.getStorageSync('uid');
        var params = {
          'uid': uid,
          'nickName': res.userInfo.nickName,
          'gender': res.userInfo.gender,
          'country': res.userInfo.country,
          'province': res.userInfo.province,
          'city': res.userInfo.city,
          'avatarUrl': res.userInfo.avatarUrl,
        }
       wx.request({
        url: app.globalData.url + app.interfaceAddress.perfectUserInfo,
        method: 'post',
        dataType: 'json',
        data: {
          info: params
        },
        success: function (res) {
          console.log(res)
        }
      })
      }
    })
  },
});